
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module TileStache.S3</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="TileStache.html"><font color="#ffffff">TileStache</font></a>.S3</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a></font></td></tr></table>
    <p><tt>Caches&nbsp;tiles&nbsp;to&nbsp;Amazon&nbsp;S3.<br>
&nbsp;<br>
Requires&nbsp;boto&nbsp;(2.0+):<br>
&nbsp;&nbsp;<a href="http://pypi.python.org/pypi/boto">http://pypi.python.org/pypi/boto</a><br>
&nbsp;<br>
Example&nbsp;configuration:<br>
&nbsp;<br>
&nbsp;&nbsp;"cache":&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;"name":&nbsp;"S3",<br>
&nbsp;&nbsp;&nbsp;&nbsp;"bucket":&nbsp;"&lt;bucket&nbsp;name&gt;",<br>
&nbsp;&nbsp;&nbsp;&nbsp;"access":&nbsp;"&lt;access&nbsp;key&gt;",<br>
&nbsp;&nbsp;&nbsp;&nbsp;"secret":&nbsp;"&lt;secret&nbsp;key&gt;"<br>
&nbsp;&nbsp;}<br>
&nbsp;<br>
S3&nbsp;cache&nbsp;parameters:<br>
&nbsp;<br>
&nbsp;&nbsp;bucket<br>
&nbsp;&nbsp;&nbsp;&nbsp;Required&nbsp;bucket&nbsp;name&nbsp;for&nbsp;S3.&nbsp;If&nbsp;it&nbsp;doesn't&nbsp;exist,&nbsp;it&nbsp;will&nbsp;be&nbsp;created.<br>
&nbsp;<br>
&nbsp;&nbsp;access<br>
&nbsp;&nbsp;&nbsp;&nbsp;Optional&nbsp;access&nbsp;key&nbsp;ID&nbsp;for&nbsp;your&nbsp;S3&nbsp;account.<br>
&nbsp;<br>
&nbsp;&nbsp;secret<br>
&nbsp;&nbsp;&nbsp;&nbsp;Optional&nbsp;secret&nbsp;access&nbsp;key&nbsp;for&nbsp;your&nbsp;S3&nbsp;account.<br>
&nbsp;<br>
&nbsp;&nbsp;use_locks<br>
&nbsp;&nbsp;&nbsp;&nbsp;Optional&nbsp;boolean&nbsp;flag&nbsp;for&nbsp;whether&nbsp;to&nbsp;use&nbsp;the&nbsp;locking&nbsp;feature&nbsp;on&nbsp;S3.<br>
&nbsp;&nbsp;&nbsp;&nbsp;True&nbsp;by&nbsp;default.&nbsp;A&nbsp;good&nbsp;reason&nbsp;to&nbsp;set&nbsp;this&nbsp;to&nbsp;false&nbsp;would&nbsp;be&nbsp;the<br>
&nbsp;&nbsp;&nbsp;&nbsp;additional&nbsp;price&nbsp;and&nbsp;time&nbsp;required&nbsp;for&nbsp;each&nbsp;lock&nbsp;set&nbsp;in&nbsp;S3.<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;path<br>
&nbsp;&nbsp;&nbsp;&nbsp;Optional&nbsp;path&nbsp;under&nbsp;bucket&nbsp;to&nbsp;use&nbsp;as&nbsp;the&nbsp;cache&nbsp;dir.&nbsp;ex.&nbsp;'cache'&nbsp;will&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;put&nbsp;tiles&nbsp;under&nbsp;&lt;bucket&gt;/cache/<br>
&nbsp;<br>
&nbsp;&nbsp;reduced_redundancy<br>
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;set&nbsp;to&nbsp;true,&nbsp;use&nbsp;S3's&nbsp;Reduced&nbsp;Redundancy&nbsp;Storage&nbsp;feature.&nbsp;Storage&nbsp;is<br>
&nbsp;&nbsp;&nbsp;&nbsp;cheaper&nbsp;but&nbsp;has&nbsp;lower&nbsp;redundancy&nbsp;on&nbsp;Amazon's&nbsp;servers.&nbsp;Defaults&nbsp;to&nbsp;false.<br>
&nbsp;<br>
Access&nbsp;and&nbsp;secret&nbsp;keys&nbsp;are&nbsp;under&nbsp;"Security&nbsp;Credentials"&nbsp;at&nbsp;your&nbsp;AWS&nbsp;account&nbsp;page:<br>
&nbsp;&nbsp;<a href="http://aws.amazon.com/account/">http://aws.amazon.com/account/</a><br>
&nbsp;&nbsp;<br>
When&nbsp;access&nbsp;or&nbsp;secret&nbsp;are&nbsp;not&nbsp;provided,&nbsp;the&nbsp;environment&nbsp;variables<br>
AWS_ACCESS_KEY_ID&nbsp;and&nbsp;AWS_SECRET_ACCESS_KEY&nbsp;will&nbsp;be&nbsp;used<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://docs.pythonboto.org/en/latest/s3_tut.html#creating-a-connection">http://docs.pythonboto.org/en/latest/s3_tut.html#creating-a-connection</a></tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="TileStache.S3.html#Cache">Cache</a>
</font></dt></dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Cache">class <strong>Cache</strong></a></font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Cache-__init__"><strong>__init__</strong></a>(self, bucket, access<font color="#909090">=None</font>, secret<font color="#909090">=None</font>, use_locks<font color="#909090">=True</font>, path<font color="#909090">=''</font>, reduced_redundancy<font color="#909090">=False</font>)</dt></dl>

<dl><dt><a name="Cache-lock"><strong>lock</strong></a>(self, layer, coord, format)</dt><dd><tt>Acquire&nbsp;a&nbsp;cache&nbsp;lock&nbsp;for&nbsp;this&nbsp;tile.<br>
&nbsp;<br>
Returns&nbsp;nothing,&nbsp;but&nbsp;blocks&nbsp;until&nbsp;the&nbsp;lock&nbsp;has&nbsp;been&nbsp;acquired.<br>
Does&nbsp;nothing&nbsp;and&nbsp;returns&nbsp;immediately&nbsp;if&nbsp;`use_locks`&nbsp;is&nbsp;false.</tt></dd></dl>

<dl><dt><a name="Cache-read"><strong>read</strong></a>(self, layer, coord, format)</dt><dd><tt>Read&nbsp;a&nbsp;cached&nbsp;tile.</tt></dd></dl>

<dl><dt><a name="Cache-remove"><strong>remove</strong></a>(self, layer, coord, format)</dt><dd><tt>Remove&nbsp;a&nbsp;cached&nbsp;tile.</tt></dd></dl>

<dl><dt><a name="Cache-save"><strong>save</strong></a>(self, body, layer, coord, format)</dt><dd><tt>Save&nbsp;a&nbsp;cached&nbsp;tile.</tt></dd></dl>

<dl><dt><a name="Cache-unlock"><strong>unlock</strong></a>(self, layer, coord, format)</dt><dd><tt>Release&nbsp;a&nbsp;cache&nbsp;lock&nbsp;for&nbsp;this&nbsp;tile.</tt></dd></dl>

</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-strptime"><strong>strptime</strong></a>(...)</dt><dd><tt><a href="#-strptime">strptime</a>(string,&nbsp;format)&nbsp;-&gt;&nbsp;struct_time<br>
&nbsp;<br>
Parse&nbsp;a&nbsp;string&nbsp;to&nbsp;a&nbsp;time&nbsp;tuple&nbsp;according&nbsp;to&nbsp;a&nbsp;format&nbsp;specification.<br>
See&nbsp;the&nbsp;library&nbsp;reference&nbsp;manual&nbsp;for&nbsp;formatting&nbsp;codes&nbsp;(same&nbsp;as&nbsp;strftime()).</tt></dd></dl>
 <dl><dt><a name="-tile_key"><strong>tile_key</strong></a>(layer, coord, format, path<font color="#909090">=''</font>)</dt><dd><tt>Return&nbsp;a&nbsp;tile&nbsp;key&nbsp;string.</tt></dd></dl>
 <dl><dt><a name="-time"><strong>time</strong></a>(...)</dt><dd><tt><a href="#-time">time</a>()&nbsp;-&gt;&nbsp;floating&nbsp;point&nbsp;number<br>
&nbsp;<br>
Return&nbsp;the&nbsp;current&nbsp;time&nbsp;in&nbsp;seconds&nbsp;since&nbsp;the&nbsp;Epoch.<br>
Fractions&nbsp;of&nbsp;a&nbsp;second&nbsp;may&nbsp;be&nbsp;present&nbsp;if&nbsp;the&nbsp;system&nbsp;clock&nbsp;provides&nbsp;them.</tt></dd></dl>
</td></tr></table>
</body></html>